package com.zxx.order.ui.adapter

import android.annotation.SuppressLint
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.zqq.baselibrary.ext.loadUrl
import com.zqq.baselibrary.ui.adapter.BaseRecyclerViewAdapter
import com.zqq.baselibrary.utils.YuanFenConverter
import com.zxx.order.R
import com.zxx.order.service.bean.OrderGoods
import kotlinx.android.synthetic.main.layout_order_goods_item.view.*

/**
 * 订单中商品列表
 * wc
 * @author zqq on 2019/6/29.
 */
class OrderGoodsAdapter(context: Context) : BaseRecyclerViewAdapter<OrderGoods, OrderGoodsAdapter.ViewHolder>(context) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view: View = LayoutInflater.from(mContext).inflate(R.layout.layout_order_goods_item, parent, false)
        return ViewHolder(view)
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        val model = dataList[position]

        holder.itemView.mGoodsIconIv.loadUrl(model.goodsIcon)
        holder.itemView.mGoodsDescTv.text = model.goodsDesc
        holder.itemView.mGoodsSkuTv.text = model.goodsSku
        holder.itemView.mGoodsPriceTv.text = YuanFenConverter.changeF2YWithUnit(model.goodsPrice)
        holder.itemView.mGoodsCountTv.text = "x${model.goodsCount}"

    }


    class ViewHolder(view: View) : RecyclerView.ViewHolder(view)

}